package com.zuikaku.nettydemo.client;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class MyNettyClientHandler extends SimpleChannelInboundHandler<String> {
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, String s) throws Exception {
        System.out.println("来自服务端的消息："+s);
    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
       for(int i=1;i<=100;i++) {
           ctx.writeAndFlush("你好，我是客户端");
       }
    }

    @Override
    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
        System.out.println("服务端已离线");
    }
}
